const loginRequest = (userInfo) => {
	return new Promise((resolve, reject) => {
		uni.login({
			success(res) {
				if (res.code) {
					uni.request({
						url: 'https://yskj.cafaic.com/jeecg-boot/fleamarket/QQLogin',
						data: {
							code: res.code,
							avatarUrl: userInfo.avatarUrl,
							city: userInfo.city,
							country: userInfo.country,
							gender: userInfo.gender,
							nickName: userInfo.nickName
						},
						method: 'POST',
						success: (result) => {
							if (result.data.success) {
								let fmUserName = result.data.result
								uni.setStorageSync('userInfo', fmUserName)
								resolve(result.data)
							} else {
								uni.showToast({
									title: '登录失败',
									icon: 'none'
								})
								reject(result.data)
							}
						},
						fail: (e) => {
							uni.showToast({
								title: '登录失败',
								icon: 'none'
							})
							reject(e)
						}
					})
				}
			}
		})
	})


}


module.exports = {
	loginRequest
}
